package com.shouer.doc.ui.conversation.dialog;

import android.content.Context;
import android.view.View;

import com.shouer.doc.R;

import com.shouer.doc.dialog.DialogDismissListener;

/**
 * Created by YYY-Work on 2017/4/17.
 */

public class SelectCardDialogUtil implements DialogDismissListener{

    private static SelectCardDialogUtil instance;

    private SelectCardDialog mDialog;

    public static SelectCardDialogUtil getInstance() {
        if (instance == null) {
            synchronized (SelectCardDialogUtil.class) {
                if (instance == null) {
                    instance = new SelectCardDialogUtil();
                }
            }
        }
        return instance;
    }


    public void show(Context context,SelectCardDialog.OnCardSelectListener selectListener)
    {
        if (mDialog==null||!mDialog.isShowing())
        {
            mDialog=new SelectCardDialog(context, R.style.dialog_untran);
        }

        mDialog.withCardSelectListener(selectListener).withDialogDismissListener(SelectCardDialogUtil.this).show();
        mDialog.setCanceledOnTouchOutside(true);
    }


    public void dismiss()
    {
        if (null!=mDialog&&mDialog.isShowing())
        {
            mDialog.dismiss();
        }
    }

    @Override
    public void onDialogDismiss() {
        mDialog=null;
    }
}
